package fr.lip6.meta.ple.generation.strategy;

import java.util.ArrayList;
import java.util.Collection;

import artefact.umlClassDiagram.CreateOperation;

import fr.lip6.meta.ple.constraintsextraction.constraint.Constraint;
import fr.lip6.meta.ple.featureIdentification.Feature;
import fr.lip6.meta.ple.featureIdentification.Product;


/**
 * Context of extension strategy (FeatureHouse, AspectJ, ...)
 * for features generation
 * 
 * @author Simon Grandsire
 *
 */
public class GenerationContext {
	private ProcessConstraintStrategy processConstraintStrategy;
	private ProductLineConstructionStrategy constructionStrategy;
	private ReadXmiStrategy readXmiStrategy;
	private GenerateFromXmiStrategy generateFromXmiStrategy;

	public GenerationContext(	ProcessConstraintStrategy constraint,
								ProductLineConstructionStrategy construction,
								ReadXmiStrategy readXmi	) {
		this.processConstraintStrategy = constraint;
		this.constructionStrategy = construction;
		this.readXmiStrategy = readXmi;
	}
	
	/*
	 * ProcessConstraintStrategy operations
	 */
	
	public ArrayList<String> getOperationVariables(CreateOperation co) {
		return processConstraintStrategy.getOperationVariables(co);
	}
	
	/*
	 * ProductFeatureGeneratorStrategy operations
	 */
	
	public void generateFeatureModel(Collection<Feature> features, ArrayList<Constraint> rules) {
		constructionStrategy.generateFeatureModel(features, rules);
	}
	
	public void construct(Collection<Feature> features, Collection<Product> products) {
		constructionStrategy.construct(features, products);
	}
	
	// getters and setters //

	public ProcessConstraintStrategy getProcessConstraintStrategy() {
		return processConstraintStrategy;
	}

	public void setProcessConstraintStrategy(ProcessConstraintStrategy constraintStrategy) {
		this.processConstraintStrategy = constraintStrategy;
	}
	
	public ProductLineConstructionStrategy getConstructionStrategy() {
		return constructionStrategy;
	}

	public void setConstructionStrategy(ProductLineConstructionStrategy constructionStrategy) {
		this.constructionStrategy = constructionStrategy;
	}
	
	public void setProducts(Collection<Product> products) {
		this.constructionStrategy.setProducts(products);
	}
	
	public GenerateFromXmiStrategy getGenerateFromXmiStrategy() {
		return generateFromXmiStrategy;
	}

	public void setGenerateFromXmiStrategy(
			GenerateFromXmiStrategy generateFromXmiStrategy) {
		this.generateFromXmiStrategy = generateFromXmiStrategy;
	}

	public ReadXmiStrategy getReadXmiStrategy() {
		return readXmiStrategy;
	}

	public void setReadXmiStrategy(ReadXmiStrategy readXmiStrategy) {
		this.readXmiStrategy = readXmiStrategy;
	}
}